/**
 * @author 黄海峰 2021/4/15 10:07
 * */

// 常量的定义
val x = 1 + 1
//x = 3 常量的定义，不允许赋值
print(x)

val x1: Int = 1 + 1
print(x1)

// 变量的定义
var y: Int = 1 + 1
y = 5
print(y)


// 块代码 blocks
println({
  val x = 1 + 1
  x + 1
})

// -----函数定义-----

// 匿名函数 anonymous function
val addOne = (x: Int) => x + 1
print(addOne(1))

// 多参数匿名函数
val add = (x: Int, y: Int) => x + y
print(add(10, 20))

// 无参匿名函数
val getTheScore = () => 100
print(getTheScore())

// -----方法定义-----
def addMethod(x: Int, y: Int): Int = x + y
print(addMethod(10, 20))

def addThenMultiply(x: Int, y: Int)(multiplier: Int): Int = (x + y) * multiplier
print(addThenMultiply(2, 3)(10))

def addThenMultiply(x: Int, y: Int)(multiplier: Int): Int = (x + y) * multiplier
print(addThenMultiply(2, 3)(10))

def addThenMultiply(x: Int, y: Int)(multiplier: Int)(plusNum: Int): Int = (x + y + plusNum) * multiplier
print(addThenMultiply(2, 3)(10)(11))

def addThenMultiply(x: Int, y: Int)(multiplier: Int): Int = (x + y) * multiplier
print(addThenMultiply(2, 3)(10))

// 无参方法
def getUserName: String = "dean"
print(getUserName)

def getSquareString(input: Double): String = {
  val square = input * input
  square.toString
}
print(getSquareString(1.5))


























